<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.model.User"%>

<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="../images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台 &gt;&gt; 系统管理&gt;&gt; 添加二级单位
</div>

<%
{
%>
<div class="tt">添加二级单位</div>
<div class="content">
	<table align="center" border="0" width="700" cellpadding="0"
		cellspacing="0">
		<tr>
			<td colspan="2" class="td1" height="35">
				<span style="margin-left: 30px">一级单位：</span>
				<span id="depart1SelectSpan">
				<%@include file="depart_select/depart1_select_section.jsp" %>
				</span>
				<br />
				<span style="margin-left: 30px">二级单位：</span>
				<span id="depart2NameSpan">
				<input type="text" id="depart2Name" name="depart2Name" value=""/>
				</span>			
			</td>
		</tr>
		<tr>
			<td colspan="2" class="td1" align="center">
				<input type="button" value="添加" onclick="addDepart2()" />
				<input type="button" value="取消" onclick="cancelAdd()" />
			</td>
		</tr>
	</table>
</div>
<script type="text/javascript">
function cancelAdd(){
	var depart1ID = getElementValueByID('depart1');
	loadPageSection(
			'<%=request.getContextPath()%>'+'/admin/department3_role.jsp', 
			'mainContentDiv', 
			{
				depart1ID:depart1ID
			}, 
			true
	); 	
}

function addDepart2() {
	var depart1ID = getElementValueByID('depart1');
	var depart2Name = getElementValueByID('depart2Name');
	if(depart2Name == '' || depart2Name == null || depart2Name == 'undefined'){
		$.dialog.alert('二级单位');
		return;
	}
	
$.dialog.confirm('您确认添加吗？', function(){
	openWaitingDialog('waitingDialog');
	$.ajax({
		type:'post',
		url:'add_depart2_process.jsp',
		data:{		
			depart1ID: depart1ID,
			depart2Name: depart2Name
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {	
					var depart2ID = obj.depart2ID;
					$.dialog('添加成功！', function() { 
						loadPageSection(
								'<%=request.getContextPath()%>' + '/admin/department3_role.jsp', 
								'mainContentDiv', 
								{
									depart1ID: depart1ID, 
									depart2ID: depart2ID
								}, 
								true
						); 
					});					
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
});
}
</script>
<%
}
%>

